﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HYBYSoft.Company.Models;

namespace HYBYSoft.Company.WebSite.Controllers
{
    public class TopicController : Controller
    {
        /// <summary>
        /// 数据库实体上下文对象
        /// </summary>
        CompanySiteEntities _dbContext = new CompanySiteEntities();

        /// <summary>
        /// 文章列表页面Get请求
        /// </summary>
        /// <param name="id">类别编号</param>
        /// <returns></returns>        
        public ActionResult Index(int id)
        {            
            var topic = from t in _dbContext.Articles
                        join c in _dbContext.Categories on t.CategoryID equals c.CategoryID
                        where t.CategoryID == id && t.IsRelease == 1
                        orderby t.CreateTime descending
                        select t;

            return View(topic);
        }
    }
}
